package com.example.springboot005tx.mapper;

import com.example.springboot005tx.pojo.User;
import com.example.springboot005tx.provider.UserProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {

    @InsertProvider(type = UserProvider.class, method = "insert")
    @ResultMap("user")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    int insert(User user);

    @SelectProvider(type = UserProvider.class, method = "selectById")
    @ResultMap("user")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    User selectById(Integer id);

    @SelectProvider(type = UserProvider.class, method = "selectAll")
    @ResultMap("user")
    List<User> selectAll();
}
